package listStudy;

import common.utils.ListNode;

public class FindFirstCommonNode2 {

    public static void main(String[] args) {

    }

    public ListNode FindFirstCommonNode(ListNode pHead1, ListNode pHead2) {
        ListNode ta = pHead1;
        ListNode tb = pHead2;
        while (ta != tb){
            ta = (ta == null ? pHead2 : ta.next);
            tb = (tb == null ? pHead1 : tb.next);
        }
        return ta;
    }
}
